<?php

namespace App\Models\Entity\Asset\Vlive;

use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class Vcstream
 * @package App\Models\Entity\Asset\Vlive
 * @version December 11, 2017, 10:26 am CST
 *
 * @property \App\Models\Entity\Asset\Vlive\Vchan vchan
 * @property string cstream_no
 * @property string name
 * @property string title
 * @property string subtitle
 * @property string short_sesc
 * @property string long_desc
 * @property string duration
 * @property string type
 * @property string vcodec
 * @property string acodec
 * @property string bitrate
 * @property string timeshift
 * @property timestamp created_at
 * @property timestamp updated_at
 * @property string Vchan
 */
class Vcstream extends Model
{
    use SoftDeletes;


    public $table = 'vcstreams';
    

    protected $dates = ['deleted_at'];


    public $fillable = [
        'cstream_no',
        'name',
        'title',
        'subtitle',
        'short_sesc',
        'long_desc',
        'duration',
        'type',
        'vcodec',
        'acodec',
        'bitrate',
        'timeshift',
        'resolution_id',
        'url',
        'listorder',
        'created_at',
        'updated_at'
    ];

    /**
     * The attributes that should be casted to native types.
     *
     * @var array
     */
    protected $casts = [
        'cstream_no' => 'string',
        'name' => 'string',
        'title' => 'string',
        'subtitle' => 'string',
        'short_sesc' => 'string',
        'long_desc' => 'string',
        'duration' => 'string',
        'resolution_id' => 'integer',
        'type' => 'string',
        'vcodec' => 'string',
        'acodec' => 'string',
        'bitrate' => 'string',
        'timeshift' => 'string',
        'url' => 'string',
        'listorder' => 'integer'
    ];

    /**
     * Validation rules
     *
     * @var array
     */
    public static $rules = [
        'cstream_no' => 'required|max:100',
        'name' => 'required',
        'title' => 'required',
        'duration' => 'numeric',
        'timeshift' => 'required',
        'Vchan' => 'required'
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     **/
    public function vchan()
    {
        return $this->belongsTo(\App\Models\Entity\Asset\Vlive\Vchan::class, 'id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     **/
    public function resolution()
    {
        return $this->hasOne(\App\Models\Common\Enumdata\Video\Resolution::class, 'id', 'resolution_id');
    }
}
